{extend name="../../base/view/common/base" /}
<!-- 主体 -->
{block name="body"}
<link href="{__STATIC__}/home/other/formSelects-v4.css" rel="stylesheet" />
<script src="{__STATIC__}/home/other/jquery.min.js"></script>
<script src="{__STATIC__}/home/other/formSelects-v4.min.js"></script>
<style>
    .layui-laydate-header{
        display: none;
    }
    .layui-laydate-content> table>thead{
        display: none;
    }
    .laydate-day-prev{
        display: none;
    }
    .laydate-day-next{
        display: none;
    }
</style>
<form class="layui-form p-4">
    <h3 class="pb-3">功能菜单/节点</h3>
    <table class="layui-table layui-table-form">
        <tr>
            <td class="layui-td-gray-2">客户名<font>*</font>
            </td>
            <td>
                {$detail.name|default=''}
            </td>
<!--            <td class="layui-td-gray">法定名称<font>*</font>-->
<!--            </td>-->
<!--            <td>-->
<!--               {$detail.fdName|default=''}-->
<!--            </td>-->
            <td class="layui-td-gray-2">纳税编码<font>*</font>
            </td>
            <td>
               {$detail.code|default=''}
            </td>
        </tr>
        <tr>

            <td class="layui-td-gray">注册地址
            </td>
            <td>
              {$detail.registAdd|default=''}
            </td>
            <td class="layui-td-gray-2">注册电话<font>*</font>
            </td>
            <td>
               {$detail.phoneNum|default=''}
            </td>

        </tr>
        <tr>
            <td class="layui-td-gray-2">开户行
            </td>
            <td>
                {$detail.bank|default=''}
            </td>
<!--            <td class="layui-td-gray">银行账户-->
<!--            </td>-->
<!--            <td>-->
<!--               {$detail.bankName|default=''}-->
<!--            </td>-->
            <td class="layui-td-gray-2">银行账户
            </td>
            <td>
               {$detail.bankCard|default=''}
            </td>
<!--            <td class="layui-td-gray-2">银行行号-->
<!--            </td>-->
<!--            <td>-->
<!--               {$detail.bankNum|default=''}-->
<!--            </td>-->
        </tr>
        <tr>

            <td class="layui-td-gray">销售员
            </td>
            <td>
                <select name="saleIds" disabled xm-select="selectId" lay-search>
                    <option value="">请选择</option>
                    {volist name="adminList" id= 'al'}
                    <option value="{$al.id}" {if isset($detail.saleIds)&&in_array($al.id,explode(',',$detail.saleIds))} selected {/if}>{$al.name}</option>
                    {/volist}
                </select>
            </td>
            <td class="layui-td-gray-2">备注
            </td>
            <td>
               {$detail.remark|default=''}
            </td>
        </tr>
        <tr>
            <td colspan="6"><h4>联系人信息</h4></td>
        </tr>
        <tr>
            <td colspan="6">
                <table class="layui-table">
                    <thead>
                        <tr>
                            <th>联系人</th>
                            <th>职务</th>
                            <th>联系地址</th>
                            <th>联系电话</th>
                            <th>操作
<!--                                <a href="javascript:" class="layui-btn layui-btn-xs" onclick="addContact('{$detail.id}',1)">添加</a>-->
                            </th>
                        </tr>
                    </thead>
                    <tobody>
                        {volist name="contactList" id='cl'}
                        <tr>
                            <td>{$cl.name}</td>
                            <td>{$cl.jobName}</td>
                            <td>{$cl.address}</td>
                            <td>{$cl.phone}</td>
                            <td>
<!--                                <a href="javascript:" class="layui-btn layui-btn-danger layui-btn-xs" onclick="removeContact('{$cl.id}',1)">删除</a>-->
<!--                                <a href="javascript:" class="layui-btn  layui-btn-xs" onclick="addContact('{$detail.id}',1,'{$cl.id}')">编辑</a>-->
                            </td>
                        </tr>
                        {/volist}
                    </tobody>
                </table>
            </td>
        </tr>
        <tr>
            <td colspan="6"><h4>收货人信息</h4></td>
        </tr>
        <tr>
            <td colspan="6">
                <table class="layui-table">
                    <thead>
                    <tr>
                        <th>收货人</th>
                        <th>职务</th>
                        <th>收货地址</th>
                        <th>收货电话</th>
                        <th>收货地址类型</th>
                        <th>操作
<!--                            <a href="javascript:" class="layui-btn layui-btn-xs" onclick="addContact('{$detail.id}',2)">添加</a>-->
                        </th>
                    </tr>
                    </thead>
                    <tobody>
                        {volist name="receiverList" id='rl'}
                        <tr>
                            <td>{$rl.name}</td>
                            <td>{$rl.jobName}</td>
                            <td>{$rl.address}</td>
                            <td>{$rl.phone}</td>
                            <td>{$rl.addType}</td>
                            <td>
<!--                                <a href="javascript:" class="layui-btn layui-btn-danger layui-btn-xs" onclick="removeContact('{$rl.id}',2)">删除</a>-->
<!--                                <a href="javascript:" class="layui-btn layui-btn-xs" onclick="addContact('{$detail.id}',2,'{$rl.id}')">编辑</a>-->
                            </td>
                        </tr>
                        {/volist}
                    </tobody>
                </table>
            </td>
        </tr>
    </table>
    <div class="py-3">
        <input type="hidden" name="id" value="{$id}">
<!--        <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即提交</button>-->
<!--        <button type="reset" class="layui-btn layui-btn-primary">重置</button>-->
    </div>
</form>
{/block}
<!-- /主体 -->

<!-- 脚本 -->
{block name="script"}
<script type="text/javascript">
    formSelects.render('selectId');
</script>
<script>
    const moduleInit = ['tool'];
    function gouguInit() {
        var form = layui.form,tool=layui.tool,level=0,laydate = layui.laydate;
        //监听提交
        form.on('submit(webform)', function (data) {
            let callback = function (e) {
                layer.msg(e.msg);
                if (e.code == 0) {
                    setTimeout(function(){
                        parent.parent.location.reload();
                    },1000);
                }
            }
            tool.post("{:url('add')}", data.field, callback);
            return false;
        });
        laydate.render({
            elem: '#gz_day' ,// 指定元素
            type:'date',
            format:'d'
        });
    }
    function addContact(punterId='',type=1,id='') {
        if (type==1){
            layui.tool.box("{:url('contactAdd')}?punterId="+punterId+'&id='+id,'联系人')
        }else {
            layui.tool.box("{:url('receiverAdd')}?punterId="+punterId+'&id='+id,'收货人')
        }

    }

    function removeContact(id='',type=1) {
        let url='';
        if (type==1){
            url="{:url('removeContact')}?"
        }else {
            url="{:url('removeReceiver')}"
        }
        httpRequest(url,{id:id},function (res) {
            if (res.code==0){
                location.reload()
            }
        })
    }
</script>
{/block}
<!-- /脚本 -->